import urllib.request

# GET请求的 encode方法
header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}
url = 'https://www.baidu.com/s?'
param = {
    'wd': '周杰伦',
    'sex': '男',
    'location': '中国台湾省'
}

# 对GET请求参数编码并合并
queryParam = urllib.parse.urlencode(param)
url += queryParam

# 请求，然后解码得到响应的html代码
reqObject = urllib.request.Request(url=url, headers=header)
respObjet = urllib.request.urlopen(reqObject)
html = respObjet.read().decode('UTF-8')
print(html)
